package org.wevil.repo.witcher3;

import org.wevil.entity.witcher3.Witcher3Characters;
import org.wevil.repo.BaseRepo;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

public interface Witcher3CharactersRepo extends BaseRepo<Witcher3Characters, Integer> {

    @Modifying
    @Query("update Witcher3Characters t set " +
            "t.nameEn = case when :#{#entity.nameEn} is null then t.nameEn else :#{#entity.nameEn} end, " +
            "t.nameCn = case when :#{#entity.nameCn} is null then t.nameCn else :#{#entity.nameCn} end, " +
            "t.descEn = case when :#{#entity.descEn} is null then t.descEn else :#{#entity.descEn} end, " +
            "t.descCn = case when :#{#entity.descCn} is null then t.descCn else :#{#entity.descCn} end, " +
            "t.img = case when :#{#entity.img} is null then t.img else :#{#entity.img} end " +
            "where t.id = :#{#entity.id}")
    void update(Witcher3Characters entity);
}
